package com.aliang.frame.viewmodel.admin.role;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.aliang.frame.domain.Role;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

public class RolePageResponseVM {

    /**
     * 角色ID
     */
    private Integer roleId;

    /**
     * 角色名称
     */
    private String roleName;

    /**
     * 角色拥有的菜单
     */
    private List<Integer> menuIds;

    /**
     * 备注信息
     */
    private String remark;

    /**
     * 状态（是否启用）
     */
    private Boolean status;

    /**
     * 是否已删除
     */
    private Boolean deleted;

    /**
     * 创建者ID
     */
    private Integer createBy;

    /**
     * 更新者ID
     */
    private Integer updateBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    /**
     * 是否超级管理员
     */
    private Boolean admin;

    /**
     * 角色排序
     */
    private int roleSort;

    public RolePageResponseVM(Role role) {
        this.roleId = role.getRoleId();
        this.roleName = role.getRoleName();
        this.menuIds = Arrays.stream(role.getMenus().split(",")).map(Integer::parseInt).collect(Collectors.toList());
        this.remark = role.getRemark();
        this.status = role.getStatus();
        this.deleted = role.getDeleted();
        this.createBy = role.getCreateBy();
        this.updateBy = role.getUpdateBy();
        this.createTime = role.getCreateTime();
        this.updateTime = role.getUpdateTime();
        this.admin = role.getAdmin();
        this.roleSort = role.getRoleSort();
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }


    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public Integer getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Integer createBy) {
        this.createBy = createBy;
    }

    public Integer getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(Integer updateBy) {
        this.updateBy = updateBy;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Boolean getAdmin() {
        return admin;
    }

    public void setAdmin(Boolean admin) {
        this.admin = admin;
    }

    public List<Integer> getMenuIds() {
        return menuIds;
    }

    public void setMenuIds(List<Integer> menuIds) {
        this.menuIds = menuIds;
    }

    public int getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(int roleSort) {
        this.roleSort = roleSort;
    }
}
